﻿using System;
using System.Threading;

namespace Chapter1_5
{
    public static class Program
    {
        [ThreadStatic]
        public static int _field = 0;
        public static void Main(string[] args)
        {
            new Thread(() =>
            {
                
                    for (int i = 0; i < 10; i++)
                    {

                        _field = (int)_field + 1;
                        Console.WriteLine("thread A Field value: {0}", _field);
                        Thread.Sleep(10);
                    }
                
            }).Start();

            new Thread(() =>
            {
                for (int i = 0; i < 10; i++)
                {

                    _field = (int)_field + 1;
                    Console.WriteLine("Thread B Field value: {0}", _field);
                    Thread.Sleep(10);

                }
            }).Start();

            Console.ReadLine();
        }
    }
}
